package com.bci.pwtz.service;

import java.util.List;
import java.util.Map;

import com.bci.pwtz.common.util.PaginationList;
import com.bci.pwtz.exception.PwtzDatabaseException;
import com.bci.pwtz.exception.PwtzException;
import com.bci.pwtz.mysql.model.CompanyUser;
import com.bci.pwtz.mysql.model.CompanyUserRole;
import com.bci.pwtz.mysql.model.RandomCode;
import com.bci.pwtz.mysql.model.UserCompanyRef;

/**
 * 用户服务 <br/>
 * <p>Description:<br/>
 *    <p>TODO 详细描述
 *
 * <p>For Examples <br/>
 * <PRE>
 * </PRE>
 * <p>
 */
public interface CompanyUserService
{
    /**
     * 
     * 删除用户 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: huangb<br/>
     * <p>Date: 2013-11-1-上午11:10:25<br/>
     * <p>
     * @param userId
     * @return   
     * @throws HasChildrenException 
     * @throws PwtzDatabaseException 
     *
     */
    int delete(Long userId) throws PwtzDatabaseException;
    /**
     * 
     * 获取用户信息 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: huangb<br/>
     * <p>Date: 2013-11-1-上午11:10:39<br/>
     * <p>
     * @param userId
     * @return   
     * @throws PwtzDatabaseException 
     *
     */
    CompanyUser load(Long userId) throws PwtzDatabaseException;
    
    /**
     * 
     * 根据用户名获取用户信息 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: huangb<br/>
     * <p>Date: 2013-11-1-上午11:10:39<br/>
     * <p>
     * @param userName
     * @return   
     * @throws PwtzDatabaseException 
     *
     */
    CompanyUser findUserInfo(String tel,String userPwd) throws PwtzDatabaseException;
    
    /**
     * 
     * 一句话描述 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: tonic<br/>
     * <p>Date: 2014-9-18-下午5:58:07<br/>
     * <p>
     * @param user
     * @return
     * @throws PwtzDatabaseException   
     *
     */
    int update(CompanyUser user) throws PwtzDatabaseException;
    
    int clearDeviceId(String deviceId) throws PwtzDatabaseException;
    
    String createRandomCode(Long companyId,Long companyRoleId) throws PwtzDatabaseException;
    
    int selectCountByPassword(Long companyUserId,String pwd) throws PwtzDatabaseException;
    
    /**
     * 
     * 清理过期的邀请码数据 <br/>
     * <p>定时清理已经过期邀请码数据
     * <br/>
     * <p>Author: dengwj<br/>
     * <p>Date: 2014-9-25-上午9:32:35<br/>
     * <p>
     * @throws PwtzDatabaseException   
     *
     */
    void deleteExpireData() throws PwtzDatabaseException;

    /**
     * 一句话描述 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: tonic<br/>
     * <p>Date: 2014-9-25-下午2:50:45<br/>
     * <p>
     * @param userName
     * @return
     * @throws PwtzDatabaseException   
     * 
     */
    int selectCountByName(String userName) throws PwtzDatabaseException;

    /**
     * 一句话描述 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: tonic<br/>
     * <p>Date: 2014-9-25-下午2:51:47<br/>
     * <p>
     * @param mobile
     * @return
     * @throws PwtzDatabaseException   
     * 
     */
    int selectCountByMobile(String mobile) throws PwtzDatabaseException;

    /**
     * 一句话描述 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: tonic<br/>
     * <p>Date: 2014-9-26-上午9:40:56<br/>
     * <p>
     * @param code
     * @return
     * @throws PwtzDatabaseException   
     * 
     */
    RandomCode selectRandomCode(String code) throws PwtzDatabaseException;

    /**
     * 一句话描述 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: tonic<br/>
     * <p>Date: 2014-9-26-上午9:42:31<br/>
     * <p>
     * @param user
     * @param radnomCode
     * @return
     * @throws PwtzDatabaseException   
     * 
     */
    CompanyUser register(CompanyUser user) throws PwtzDatabaseException;

    /**
     * 一句话描述 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: tonic<br/>
     * <p>Date: 2014-9-26-上午10:09:53<br/>
     * <p>
     * @param ref
     * @return
     * @throws PwtzDatabaseException   
     * 
     */
    int addUserCompanyRef(UserCompanyRef ref) throws PwtzDatabaseException;
    /**
     * 一句话描述 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: tonic<br/>
     * <p>Date: 2014-9-26-上午10:14:44<br/>
     * <p>
     * @param ref
     * @return
     * @throws PwtzDatabaseException   
     * 
     */
    int addCompanyUserRole(CompanyUserRole ref) throws PwtzDatabaseException;
    
    int updatePwdByMobile(String pwd,String mobile) throws PwtzDatabaseException;
    
    Map<Long,Integer> getUserCompanyRef(long companyUserID) throws PwtzException;
    
    PaginationList<CompanyUser> selectUserByRole(long companyRoleId, int pageSize, int pageNo) throws PwtzDatabaseException;
    
    PaginationList<CompanyUser> selectUseByLastCompanyId(long companyRoleId, long lastCompanyId, String loginName, int pageSize, int pageNo) throws PwtzDatabaseException;
    
    int deleteCompanyUserRoleByUserId(long companyUserId, long companyRoleId) throws PwtzDatabaseException;
    /**
     * 一句话描述 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: tonic<br/>
     * <p>Date: 2014-10-13-下午4:25:12<br/>
     * <p>
     * @param companyId
     * @param pageSize
     * @param pageNo
     * @return
     * @throws PwtzDatabaseException   
     * 
     */
    PaginationList<CompanyUser> selectUseByCompanyId(long companyId, int pageSize, int pageNo) throws PwtzDatabaseException;
    /**
     * 一句话描述 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: tonic<br/>
     * <p>Date: 2014-10-13-下午7:50:03<br/>
     * <p>
     * @param userId
     * @param companyId
     * @return
     * @throws PwtzDatabaseException   
     * 
     */
    int deleteRef(Long userId, Long companyId) throws PwtzDatabaseException;
    
    /**
     * 
     * 清除指定单位下的所有用户与角色的关系 <br/>
     * <p>
     * <br/>
     * <p>Author: dengwj<br/>
     * <p>Date: 2014-10-16-上午9:53:52<br/>
     * <p>
     * @param companyId
     * @return
     * @throws PwtzDatabaseException   
     *
     */
    int clearUserRoleRef(long companyUserId,long companyId) throws PwtzDatabaseException;
    
    String getCompanyUserName(Long companyUserId,int type) throws PwtzDatabaseException;
    
    public List<CompanyUser> selectUserByCompanyIds(Long companyId) throws PwtzDatabaseException;
    
    public boolean exitCompany(Long companyUserId)throws PwtzDatabaseException;
    
    public List<RandomCode> getCompanyRandomCode(Long companyId)throws PwtzDatabaseException;
    
    PaginationList<CompanyUser> selectTmepUser(int pageNo,int pageSize) throws PwtzDatabaseException;
    
    int selectTmepUserById(Long userid) throws PwtzDatabaseException;
    /**
     * 一句话描述 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: tonic<br/>
     * <p>Date: 2015-2-12-下午3:00:47<br/>
     * <p>
     * @param userName
     * @param mobile
     * @return
     * @throws PwtzDatabaseException   
     * 
     */
    CompanyUser selectUser(String userName, String mobile) throws PwtzDatabaseException;

}
